char *path;
char **result;
int pathTop;
int resultTop;

char *letterMap[10] = { // 1# letterMap是一维数组
    "", // 0
    "", // 1
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz" // 9
};

void backtracking(char *digits, int index) {
    if (pathTop == strlen(digits)) {
        char *temp = (char *)malloc(sizeof(char) * (strlen(digits) + 1));
        for(int i = 0; i < strlen(digits); i++) {
            temp[i] = path[i];
        }
        temp[strlen(digits)] = '\0';
        result[resultTop++] = temp;
        return;
    }

    int digit = digits[index] - '0';
    for(int i = 0; i < strlen(letterMap[digit]); i++) {
        path[pathTop++] = letterMap[digit][i];
        backtracking(digits, index + 1);
        pathTop--;
    }
}

char ** letterCombinations(char * digits, int* returnSize) {
        
    path = (char *)malloc(sizeof(char) * strlen(digits));
    result = (char **)malloc(sizeof(char *) * 1000);
    pathTop = resultTop = 0;

    // 2# 若digits数组中元素个数为0，返回空集
    if (strlen(digits) == 0) {
        *returnSize = resultTop; 
        return result;
    }
    else {    
        backtracking(digits, 0);
        *returnSize = resultTop;
        return result;
    }

}